package com.ja.openchat.viewmodels;

import android.app.Application;

import androidx.annotation.NonNull;

import com.ja.openchat.ui.me.PersonalDataFragment;
import com.zy.openchat.core.manager.TgEvent;
import com.ja.openchat.ui.chat.ConversationFragment;

import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import me.goldze.mvvmhabit.base.BaseModel;
import me.goldze.mvvmhabit.base.BaseViewModel;

public class ChatViewmodel extends BaseViewModel {

    private ConversationFragment conversationFragment;

    public ChatViewmodel(@NonNull Application application, BaseModel model) {
        super(application, model);
    }


    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onTgEvent(final TgEvent tg_event){
        if(conversationFragment!=null){
            conversationFragment.onTgEvent(tg_event);
        }
    }

    public void setConversationFragment(ConversationFragment conversationFragment) {
        this.conversationFragment = conversationFragment;
    }

    public void goProfileActivity() {
        startContainerActivity(PersonalDataFragment.class.getCanonicalName());
    }
}
